package cn.bsuc.crm.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author : zhuoyuan
 * @date : 2022/10/7 16:39
 * @description :
 */
@Component
@Slf4j
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject,"createDate",LocalDateTime.class,LocalDateTime.now());
        this.strictInsertFill(metaObject,"updateDate",LocalDateTime.class,LocalDateTime.now());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("====== 自动更新时间了 ======");
        this.strictUpdateFill(metaObject,"updateDate",LocalDateTime.class,LocalDateTime.now());
    }
}
